package com.cs2340.taskplusplus;

import java.util.Date;

import android.test.AndroidTestCase;

// I'm doing addTask and addLabel
// Charles: expand and task to tasklist constructor
// AJ: isDone isNotDone
// Adam: sorting methods

public class JUnitAJ extends AndroidTestCase {

	Account a;
	
    public void testSomething() throws Throwable 
    {
    	a = new Account("default");
    	a.deleteAccount("test");
    	a = new Account("test","test","test","test");
    	TaskList t = a.getMasterList();
    	t.addTask(new Task(null, "Testing 1", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	t.addTask(new Task(null, "Testing 2", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	t.addTask(new Task(null, "Testing 3", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	int i = 0;
    	for (Doable d : t.getList())
    	{
    		if (d.isDone())
    			i++;
    	}
    	assertTrue(i==0);
    	
    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (i == 1)
    			d.setDone();
    		i++;
    	}

    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (d.isDone())
    			i++;
    	}
    	assertTrue(i==1);
    	t.setDone();

    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (d.isDone())
    			i++;
    	}
    	assertTrue(i==3);
    }

    public void testSomethingElse() throws Throwable 
    {
    	a = new Account("default");
    	a.deleteAccount("test");
    	a = new Account("test","test","test","test");
    	TaskList t = a.getMasterList();
    	t.addTask(new Task(null, "Testing 1", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	t.addTask(new Task(null, "Testing 2", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	t.addTask(new Task(null, "Testing 3", "Testinger Thingy", new Date(), null, new Location(0,0)));
    	int i = 0;
    	t.setDone();
    	for (Doable d : t.getList())
    	{
    		if (!d.isDone())
    			i++;
    	}
    	assertTrue(i==0);
    	
    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (i == 1)
    			d.setNotDone();
    		i++;
    	}

    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (!d.isDone())
    			i++;
    	}
    	assertTrue(i==1);
    	t.setNotDone();

    	i = 0;
    	for (Doable d : t.getList())
    	{
    		if (!d.isDone())
    			i++;
    	}
    	assertTrue(i==3);    	
    }
    
    public void test() throws Throwable 
    {
    	
    }
    
    public void testLocation() throws Throwable
    {
    	a = new Account("default");
    	a.deleteAccount("test");
    	a = new Account("test","test","test","test");
    	TaskList t = a.getMasterList();
    	Task addable = new Task(null, "Testing 1", "Testinger Thingy", new Date(), null, new Location(0,0));
    	addable.setLocation(new Location(300000, 400000));
    	t.addTask(addable);
    	t = a.getMasterList();
    	assertTrue(t.getList().get(0).getLocation().getLat() == 300000);
    	assertTrue(t.getList().get(0).getLocation().getLon() == 400000);    	
    }
}
